package com.hzf.designer.rpc.service.impl;

import com.hzf.designer.dao.mapper.*;
import com.hzf.designer.dao.model.*;
import com.hzf.designer.rpc.api.DesignerApiService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class DesignerApiServiceImpl implements DesignerApiService {
    @Autowired
    DneedsDesignerMapper dneedsDesignerMapper;
    @Autowired
    DneedsDesignerCaseMapper dneedsDesignerCaseMapper;
    @Autowired
    DneedsDemandMapper dneedsDemandMapper;
    @Autowired
    DneedsBidMapper dneedsBidMapper;
    @Autowired
    DneedsDemandSjtMapper dneedsDemandSjtMapper;
    @Autowired
    DneedsDemandWltMapper dneedsDemandWltMapper;
    @Override
    public int installDesigner(DneedsDesigner dneedsDesigner) {
        DneedsDesignerExample example = new DneedsDesignerExample();
        example.createCriteria().andUserIdEqualTo(dneedsDesigner.getUserId());
        List<DneedsDesigner> list = dneedsDesignerMapper.selectByExample(example);
        if (0 != list.size()) {
            return 0;
        }
        return dneedsDesignerMapper.insert(dneedsDesigner);
    }
    @Override
    public List<DneedsDesigner> selectDesigner(DneedsDesignerExample dneedsDesignerExample) {
        return dneedsDesignerMapper.selectByExample(dneedsDesignerExample);
    }

    @Override
    public DneedsDesigner getDesigner(DneedsDesignerExample dneedsDesignerExample) {

        List<DneedsDesigner> list = dneedsDesignerMapper.selectByExample(dneedsDesignerExample);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateDesigner(DneedsDesigner dneedsDesigner) {
        return dneedsDesignerMapper.updateByPrimaryKey(dneedsDesigner);
    }

    @Override
    public int delectDesigner(DneedsDesigner dneedsDesigner) {
        return dneedsDesignerMapper.deleteByPrimaryKey(dneedsDesigner.getId());
    }

    @Override
    public List<DneedsDesigner> selectByPrimaryDneedsDesigner(int regionNumber, int status, long min0, long max0, long min1, long max1, long min2, long max2, long min3, long max3, long min4, long max4, long min5, long max5, long min6, long max6, long min7, long max7, long min8, long max8) {
        return dneedsDesignerMapper.selectByPrimaryDneedsDesigner(regionNumber,status, min0,max0,min1,max1,min2,max2,min3,max3,min4,max4,min5,max5,min6,max6,min7,max7,min8,max8);
    }
    @Override
    public List<DneedsDemand> selectByPrimaryDneedsDemand(int regionNumber, int status, long min0, long max0, long min1, long max1, long min2, long max2, long min3, long max3, long min4, long max4, long min5, long max5, long min6, long max6, long min7, long max7, long min8, long max8) {
        return dneedsDemandMapper.selectByPrimaryDneedsDemand(regionNumber,status, min0,max0,min1,max1,min2,max2,min3,max3,min4,max4,min5,max5,min6,max6,min7,max7,min8,max8);
    }
    @Override
    public int installDneedsDesignerCase(DneedsDesignerCase dneedsDesigner) {
        DneedsDesignerCaseExample example = new DneedsDesignerCaseExample();
        example.createCriteria().andUserIdEqualTo(dneedsDesigner.getUserId());
        List<DneedsDesignerCase> list = dneedsDesignerCaseMapper.selectByExample(example);
        if (0 != list.size()) {
            return 0;
        }
        return dneedsDesignerCaseMapper.insert(dneedsDesigner);
    }
    @Override
    public List<DneedsDesignerCase> selectDneedsDesignerCase(DneedsDesignerCaseExample dneedsDesignerCaseExample) {
        return dneedsDesignerCaseMapper.selectByExample(dneedsDesignerCaseExample);
    }

    @Override
    public DneedsDesignerCase getDneedsDesignerCase(DneedsDesignerCaseExample dneedsDesignerCaseExample) {

        List<DneedsDesignerCase> list = dneedsDesignerCaseMapper.selectByExample(dneedsDesignerCaseExample);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateDneedsDesignerCase(DneedsDesignerCase dneedsDesigner) {
        return dneedsDesignerCaseMapper.updateByPrimaryKey(dneedsDesigner);
    }

    @Override
    public int delectDneedsDesignerCase(DneedsDesignerCase dneedsDesigner) {
        return dneedsDesignerCaseMapper.deleteByPrimaryKey(dneedsDesigner.getId());
    }
    @Override
    public int installDneedsDemand(DneedsDemand data) {

        return dneedsDemandMapper.insert(data);
    }
    @Override
    public List<DneedsDemand> selectDneedsDemand(DneedsDemandExample data) {
        return dneedsDemandMapper.selectByExample(data);
    }

    @Override
    public DneedsDemand getDneedsDemand(DneedsDemandExample data) {

        List<DneedsDemand> list = dneedsDemandMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateDneedsDemand(DneedsDemand data) {
        return dneedsDemandMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectDneedsDemand(DneedsDemand data) {
        return dneedsDemandMapper.deleteByPrimaryKey(data.getId());
    }

    @Override
    public int installDneedsBid(DneedsBid data) {
        DneedsBidExample example = new DneedsBidExample();
        example.createCriteria().andUserIdEqualTo(data.getUserId()).andDemandIdEqualTo(data.getDemandId());
        List<DneedsBid> lists = dneedsBidMapper.selectByExample(example);
        if(null!=lists&&0!=lists.size()){
            return 0;
        }
         return dneedsBidMapper.insert(data);
    }

    @Override
    public List<DneedsBid> selectDneedsBid(DneedsBidExample data) {
        return dneedsBidMapper.selectByExample(data);
    }

    @Override
    public DneedsBid getDneedsBid(DneedsBidExample data) {
        List<DneedsBid> list = dneedsBidMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateDneedsBid(DneedsBid data) {
        return dneedsBidMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectDneedsBid(DneedsBid data) {
        return dneedsBidMapper.deleteByPrimaryKey(data.getId());
    }
    @Override
    public int installDneedsDemandSjt(DneedsDemandSjt data) {
        DneedsDemandSjtExample example = new DneedsDemandSjtExample();
        example.createCriteria().andDemandIdEqualTo(data.getDemandId());
        List<DneedsDemandSjt> lists = dneedsDemandSjtMapper.selectByExample(example);
        if(null!=lists&&0!=lists.size()){
            return 0;
        }
        return dneedsDemandSjtMapper.insert(data);
    }

    @Override
    public List<DneedsDemandSjt> selectDneedsDemandSjt(DneedsDemandSjtExample data) {
        return dneedsDemandSjtMapper.selectByExample(data);
    }

    @Override
    public DneedsDemandSjt getDneedsDemandSjt(DneedsDemandSjtExample data) {
        List<DneedsDemandSjt> list = dneedsDemandSjtMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateDneedsDemandSjt(DneedsDemandSjt data) {
        return dneedsDemandSjtMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectDneedsDemandSjt(DneedsDemandSjt data) {
        return dneedsDemandSjtMapper.deleteByPrimaryKey(data.getId());
    }
    @Override
    public int installDneedsDemandWlt(DneedsDemandWlt data) {
        DneedsDemandWltExample example = new DneedsDemandWltExample();
        example.createCriteria().andDemandIdEqualTo(data.getDemandId());
        List<DneedsDemandWlt> lists = dneedsDemandWltMapper.selectByExample(example);
        if(null!=lists&&0!=lists.size()){
            return 0;
        }
        return dneedsDemandWltMapper.insert(data);
    }

    @Override
    public List<DneedsDemandWlt> selectDneedsDemandWlt(DneedsDemandWltExample data) {
        return dneedsDemandWltMapper.selectByExample(data);
    }

    @Override
    public DneedsDemandWlt getDneedsDemandWlt(DneedsDemandWltExample data) {
        List<DneedsDemandWlt> list = dneedsDemandWltMapper.selectByExample(data);
        if(null!=list&&0!=list.size()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public int updateDneedsDemandWlt(DneedsDemandWlt data) {
        return dneedsDemandWltMapper.updateByPrimaryKey(data);
    }

    @Override
    public int delectDneedsDemandWlt(DneedsDemandWlt data) {
        return dneedsDemandWltMapper.deleteByPrimaryKey(data.getId());
    }
}
